<template>
  <div class="PatrolWarn">
    <div class="PatrolWarn--header">
      <div class="PatrolWarn--header__title">
        {{ warnInfo.name || '--' }}
        <img src="@/assets/images/armyScreen/playIcon.png" @click="openPlayer"/>
      </div>
      <div class="PatrolWarn--header__close" @click="closeAction"></div>
    </div>
    <div class="PatrolWarn--content">
      <div class="infolist">
        <div class="infolist--item">
          <div class="infolist--item__icon">
            <img src="@/assets/images/armyScreen/地址@2x.png"/>
          </div>
          <div class="infolist--item__value two-line" style="width: 116px;">
            姓名：{{ warnInfo.event.personName || '--' }}
          </div>
        </div>
        <div class="infolist--item">
          <div class="infolist--item__icon">
            <img src="@/assets/images/armyScreen/时间@2x.png"/>
          </div>
          <div class="infolist--item__value" style="white-space: nowrap;">
            时间：{{ warnInfo.event.time || '--' }}
          </div>
        </div>
        <div class="infolist--item">
          <div class="infolist--item__icon">
            <img src="@/assets/images/armyScreen/类型@2x.png"/>
          </div>
          <div class="infolist--item__value" style="white-space: nowrap;">
            告警类型：{{ warnInfo.event.eventName || '--' }}
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import $bus from "@/util/bus";

const props = defineProps({
  warnInfo: {
    type: Object,
    default() {
      return {}
    }
  }
})

const $emit = defineEmits(['close', 'player'])
onMounted(() => {
})

/* 关闭窗口 */
function closeAction() {
  $emit('close')
}

/* 弹出视频窗口 */
function openPlayer() {
  closeAction()
  $emit('player', props.warnInfo)
  // showPlayerPanel()
}

onBeforeMount(() => {
  $bus.on('hidePanel', closeAction)
})

onBeforeUnmount(() => {
  $bus.off('hidePanel', closeAction)
})

</script>

<style lang="scss" scoped>
.PatrolWarn {
  width: 287px;
  height: 162px;
  background-image: url('@/assets/images/armyScreen/撤防卡片_bg@2x.png');
  background-size: cover;

  display: flex;
  flex-direction: column;
  margin: 0 auto;

  &--header {
    height: 32px;
    line-height: 32px;
    padding-left: 36px;
    position: relative;

    &__title {
      font-family: PingFangSC-Medium;
      font-size: 16px;
      color: #FFFFFF;
      letter-spacing: 0;
      font-weight: 500;

      img {
        display: inline-block;
        height: 24px;
        width: 24px;
        position: absolute;
        top: 5px;
        right: 40px;
        cursor: pointer;
        margin-left: 8px;
      }
    }

    &__close {
      width: 24px;
      height: 24px;
      position: absolute;
      right: 8px;
      top: 3px;
      color: #0DFDF0;
      cursor: pointer;
    }
  }

  &--content {
    flex-grow: 1;
    padding: 12px 16px 0 16px;

    &__img {
      width: 146px;
      height: 84px;

      img {
        width: 100%;
        max-height: 84px;
      }
    }

    .infolist {
      height: 84px;
      line-height: 20px;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      margin-top: 12px;

      &--item {
        display: flex;

        &__icon {
          width: 16px;
          height: 16px;
          margin-right: 2px;
          position: relative;
          top: 2px;

          img {
            width: 100%;
            height: auto;
          }
        }

        &__value {
          flex-grow: 1;
          font-family: PingFangSC-Regular;
          font-size: 12px;
          color: rgba(255, 255, 255, 0.8);
          letter-spacing: 0;
          font-weight: 400;
        }
      }
    }

  }
}
</style>
